{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--BOOK_INFORMATION-->\n",
    "<a href=\"https://user-images.githubusercontent.com/19553554/71825144-2d568180-30d6-11ea-8ee0-63c849cfd934.png\" target=\"_blank\"><img align=\"left\" style=\"width: 76px; height: 100px; background: white; padding: 1px; border: 1px solid black; margin-right:10px;\"></a>\n",
    "*pyecharts 是一个用于生成 Echarts 图表的类库。Echarts 是百度开源的一个数据可视化 JS 库。用 Echarts 生成的图可视化效果非常棒，为了与 Python 进行对接，方便在 Python 中直接使用数据生成图，于是有人开发出了这个项目[GitHub](https://github.com/pyecharts/pyecharts) .*\n",
    "\n",
    "*Note.建议本程序在参看https://github.com/pyecharts/pyecharts 的安装步骤后再运行； 本程序所有的例子都是从官方提供的样例代码[GitHub](https://github.com/pyecharts/pyecharts-gallery)中提取的,如果对某个API有疑问建议在IDE里面查看*\n",
    "\n",
    "*Echart类型图种大全:https://echarts.apache.org/examples/zh/#chart-type-line pyecharts图导入到ppt中的方法:https://baijiahao.baidu.com/s?id=1663839456876951842&wfr=spider&for=pc.*\n",
    "\n",
    "*作者: LBQ; 时间:2020/7/24. 邮箱:779660843@qq.com*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ⅲ.百度地图(BMap)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "ename": "KeyError",
     "evalue": "\"'https://api.map.baidu.com/api?v=2.0&ak='. closest match: 'echarts-liquidfill' with ratio 0.246\"",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-7-8a1b583aa9ec>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     14\u001b[0m     \u001b[0;31m#.render(\"bmap_base.html\")\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     15\u001b[0m )\n\u001b[0;32m---> 16\u001b[0;31m \u001b[0mc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_javascript\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     17\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrender_notebook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/mixins.py\u001b[0m in \u001b[0;36mload_javascript\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m      9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     10\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mload_javascript\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mengine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_javascript\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     12\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     13\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/render/engine.py\u001b[0m in \u001b[0;36mload_javascript\u001b[0;34m(chart)\u001b[0m\n\u001b[1;32m    113\u001b[0m     \u001b[0mscripts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    114\u001b[0m     \u001b[0;32mfor\u001b[0m \u001b[0mdep\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mchart\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjs_dependencies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 115\u001b[0;31m         \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mext\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mFILENAMES\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mdep\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    116\u001b[0m         \u001b[0mscripts\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"{}{}.{}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mCurrentConfig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mONLINE_HOST\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mext\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    117\u001b[0m     \u001b[0;32mreturn\u001b[0m \u001b[0mJavascript\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlib\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mscripts\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/datasets/__init__.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, lookfor)\u001b[0m\n\u001b[1;32m     84\u001b[0m             raise KeyError(\n\u001b[1;32m     85\u001b[0m                 \u001b[0;34m\"'%s'. closest match: '%s' with ratio %.3f\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 86\u001b[0;31m                 \u001b[0;34m%\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlookfor\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mratio\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     87\u001b[0m             )\n\u001b[1;32m     88\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mKeyError\u001b[0m: \"'https://api.map.baidu.com/api?v=2.0&ak='. closest match: 'echarts-liquidfill' with ratio 0.246\""
     ]
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import BMap\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "c = (\n",
    "    BMap()\n",
    "    .add_schema(baidu_ak=\"FAKE_AK\", center=[120.13066322374, 30.240018034923])\n",
    "    .add(\n",
    "        \"bmap\",\n",
    "        [list(z) for z in zip(Faker.provinces, Faker.values())],\n",
    "        label_opts=opts.LabelOpts(formatter=\"{b}\"),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"BMap-基本示例\"))\n",
    "    #.render(\"bmap_base.html\")\n",
    ")\n",
    "c.load_javascript()\n",
    "c.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "ename": "AttributeError",
     "evalue": "'str' object has no attribute 'render_notebook'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-4-e872376afdf2>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m    518\u001b[0m         \u001b[0mtooltip_opts\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mopts\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTooltipOpts\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrigger\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"item\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    519\u001b[0m     )\n\u001b[0;32m--> 520\u001b[0;31m     \u001b[0;34m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"air_quality_baidu_map.html\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    521\u001b[0m \u001b[0;31m#     .load_javascript()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    522\u001b[0m     \u001b[0;34m.\u001b[0m\u001b[0mrender_notebook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mAttributeError\u001b[0m: 'str' object has no attribute 'render_notebook'"
     ]
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import BMap\n",
    "\n",
    "data = [\n",
    "    [\"海门\", 9],\n",
    "    [\"鄂尔多斯\", 12],\n",
    "    [\"招远\", 12],\n",
    "    [\"舟山\", 12],\n",
    "    [\"齐齐哈尔\", 14],\n",
    "    [\"盐城\", 15],\n",
    "    [\"赤峰\", 16],\n",
    "    [\"青岛\", 18],\n",
    "    [\"乳山\", 18],\n",
    "    [\"金昌\", 19],\n",
    "    [\"泉州\", 21],\n",
    "    [\"莱西\", 21],\n",
    "    [\"日照\", 21],\n",
    "    [\"胶南\", 22],\n",
    "    [\"南通\", 23],\n",
    "    [\"拉萨\", 24],\n",
    "    [\"云浮\", 24],\n",
    "    [\"梅州\", 25],\n",
    "    [\"文登\", 25],\n",
    "    [\"上海\", 25],\n",
    "    [\"攀枝花\", 25],\n",
    "    [\"威海\", 25],\n",
    "    [\"承德\", 25],\n",
    "    [\"厦门\", 26],\n",
    "    [\"汕尾\", 26],\n",
    "    [\"潮州\", 26],\n",
    "    [\"丹东\", 27],\n",
    "    [\"太仓\", 27],\n",
    "    [\"曲靖\", 27],\n",
    "    [\"烟台\", 28],\n",
    "    [\"福州\", 29],\n",
    "    [\"瓦房店\", 30],\n",
    "    [\"即墨\", 30],\n",
    "    [\"抚顺\", 31],\n",
    "    [\"玉溪\", 31],\n",
    "    [\"张家口\", 31],\n",
    "    [\"阳泉\", 31],\n",
    "    [\"莱州\", 32],\n",
    "    [\"湖州\", 32],\n",
    "    [\"汕头\", 32],\n",
    "    [\"昆山\", 33],\n",
    "    [\"宁波\", 33],\n",
    "    [\"湛江\", 33],\n",
    "    [\"揭阳\", 34],\n",
    "    [\"荣成\", 34],\n",
    "    [\"连云港\", 35],\n",
    "    [\"葫芦岛\", 35],\n",
    "    [\"常熟\", 36],\n",
    "    [\"东莞\", 36],\n",
    "    [\"河源\", 36],\n",
    "    [\"淮安\", 36],\n",
    "    [\"泰州\", 36],\n",
    "    [\"南宁\", 37],\n",
    "    [\"营口\", 37],\n",
    "    [\"惠州\", 37],\n",
    "    [\"江阴\", 37],\n",
    "    [\"蓬莱\", 37],\n",
    "    [\"韶关\", 38],\n",
    "    [\"嘉峪关\", 38],\n",
    "    [\"广州\", 38],\n",
    "    [\"延安\", 38],\n",
    "    [\"太原\", 39],\n",
    "    [\"清远\", 39],\n",
    "    [\"中山\", 39],\n",
    "    [\"昆明\", 39],\n",
    "    [\"寿光\", 40],\n",
    "    [\"盘锦\", 40],\n",
    "    [\"长治\", 41],\n",
    "    [\"深圳\", 41],\n",
    "    [\"珠海\", 42],\n",
    "    [\"宿迁\", 43],\n",
    "    [\"咸阳\", 43],\n",
    "    [\"铜川\", 44],\n",
    "    [\"平度\", 44],\n",
    "    [\"佛山\", 44],\n",
    "    [\"海口\", 44],\n",
    "    [\"江门\", 45],\n",
    "    [\"章丘\", 45],\n",
    "    [\"肇庆\", 46],\n",
    "    [\"大连\", 47],\n",
    "    [\"临汾\", 47],\n",
    "    [\"吴江\", 47],\n",
    "    [\"石嘴山\", 49],\n",
    "    [\"沈阳\", 50],\n",
    "    [\"苏州\", 50],\n",
    "    [\"茂名\", 50],\n",
    "    [\"嘉兴\", 51],\n",
    "    [\"长春\", 51],\n",
    "    [\"胶州\", 52],\n",
    "    [\"银川\", 52],\n",
    "    [\"张家港\", 52],\n",
    "    [\"三门峡\", 53],\n",
    "    [\"锦州\", 54],\n",
    "    [\"南昌\", 54],\n",
    "    [\"柳州\", 54],\n",
    "    [\"三亚\", 54],\n",
    "    [\"自贡\", 56],\n",
    "    [\"吉林\", 56],\n",
    "    [\"阳江\", 57],\n",
    "    [\"泸州\", 57],\n",
    "    [\"西宁\", 57],\n",
    "    [\"宜宾\", 58],\n",
    "    [\"呼和浩特\", 58],\n",
    "    [\"成都\", 58],\n",
    "    [\"大同\", 58],\n",
    "    [\"镇江\", 59],\n",
    "    [\"桂林\", 59],\n",
    "    [\"张家界\", 59],\n",
    "    [\"宜兴\", 59],\n",
    "    [\"北海\", 60],\n",
    "    [\"西安\", 61],\n",
    "    [\"金坛\", 62],\n",
    "    [\"东营\", 62],\n",
    "    [\"牡丹江\", 63],\n",
    "    [\"遵义\", 63],\n",
    "    [\"绍兴\", 63],\n",
    "    [\"扬州\", 64],\n",
    "    [\"常州\", 64],\n",
    "    [\"潍坊\", 65],\n",
    "    [\"重庆\", 66],\n",
    "    [\"台州\", 67],\n",
    "    [\"南京\", 67],\n",
    "    [\"滨州\", 70],\n",
    "    [\"贵阳\", 71],\n",
    "    [\"无锡\", 71],\n",
    "    [\"本溪\", 71],\n",
    "    [\"克拉玛依\", 72],\n",
    "    [\"渭南\", 72],\n",
    "    [\"马鞍山\", 72],\n",
    "    [\"宝鸡\", 72],\n",
    "    [\"焦作\", 75],\n",
    "    [\"句容\", 75],\n",
    "    [\"北京\", 79],\n",
    "    [\"徐州\", 79],\n",
    "    [\"衡水\", 80],\n",
    "    [\"包头\", 80],\n",
    "    [\"绵阳\", 80],\n",
    "    [\"乌鲁木齐\", 84],\n",
    "    [\"枣庄\", 84],\n",
    "    [\"杭州\", 84],\n",
    "    [\"淄博\", 85],\n",
    "    [\"鞍山\", 86],\n",
    "    [\"溧阳\", 86],\n",
    "    [\"库尔勒\", 86],\n",
    "    [\"安阳\", 90],\n",
    "    [\"开封\", 90],\n",
    "    [\"济南\", 92],\n",
    "    [\"德阳\", 93],\n",
    "    [\"温州\", 95],\n",
    "    [\"九江\", 96],\n",
    "    [\"邯郸\", 98],\n",
    "    [\"临安\", 99],\n",
    "    [\"兰州\", 99],\n",
    "    [\"沧州\", 100],\n",
    "    [\"临沂\", 103],\n",
    "    [\"南充\", 104],\n",
    "    [\"天津\", 105],\n",
    "    [\"富阳\", 106],\n",
    "    [\"泰安\", 112],\n",
    "    [\"诸暨\", 112],\n",
    "    [\"郑州\", 113],\n",
    "    [\"哈尔滨\", 114],\n",
    "    [\"聊城\", 116],\n",
    "    [\"芜湖\", 117],\n",
    "    [\"唐山\", 119],\n",
    "    [\"平顶山\", 119],\n",
    "    [\"邢台\", 119],\n",
    "    [\"德州\", 120],\n",
    "    [\"济宁\", 120],\n",
    "    [\"荆州\", 127],\n",
    "    [\"宜昌\", 130],\n",
    "    [\"义乌\", 132],\n",
    "    [\"丽水\", 133],\n",
    "    [\"洛阳\", 134],\n",
    "    [\"秦皇岛\", 136],\n",
    "    [\"株洲\", 143],\n",
    "    [\"石家庄\", 147],\n",
    "    [\"莱芜\", 148],\n",
    "    [\"常德\", 152],\n",
    "    [\"保定\", 153],\n",
    "    [\"湘潭\", 154],\n",
    "    [\"金华\", 157],\n",
    "    [\"岳阳\", 169],\n",
    "    [\"长沙\", 175],\n",
    "    [\"衢州\", 177],\n",
    "    [\"廊坊\", 193],\n",
    "    [\"菏泽\", 194],\n",
    "    [\"合肥\", 229],\n",
    "    [\"武汉\", 273],\n",
    "    [\"大庆\", 279],\n",
    "]\n",
    "\n",
    "geoCoordMap = {\n",
    "    \"海门\": [121.15, 31.89],\n",
    "    \"鄂尔多斯\": [109.781327, 39.608266],\n",
    "    \"招远\": [120.38, 37.35],\n",
    "    \"舟山\": [122.207216, 29.985295],\n",
    "    \"齐齐哈尔\": [123.97, 47.33],\n",
    "    \"盐城\": [120.13, 33.38],\n",
    "    \"赤峰\": [118.87, 42.28],\n",
    "    \"青岛\": [120.33, 36.07],\n",
    "    \"乳山\": [121.52, 36.89],\n",
    "    \"金昌\": [102.188043, 38.520089],\n",
    "    \"泉州\": [118.58, 24.93],\n",
    "    \"莱西\": [120.53, 36.86],\n",
    "    \"日照\": [119.46, 35.42],\n",
    "    \"胶南\": [119.97, 35.88],\n",
    "    \"南通\": [121.05, 32.08],\n",
    "    \"拉萨\": [91.11, 29.97],\n",
    "    \"云浮\": [112.02, 22.93],\n",
    "    \"梅州\": [116.1, 24.55],\n",
    "    \"文登\": [122.05, 37.2],\n",
    "    \"上海\": [121.48, 31.22],\n",
    "    \"攀枝花\": [101.718637, 26.582347],\n",
    "    \"威海\": [122.1, 37.5],\n",
    "    \"承德\": [117.93, 40.97],\n",
    "    \"厦门\": [118.1, 24.46],\n",
    "    \"汕尾\": [115.375279, 22.786211],\n",
    "    \"潮州\": [116.63, 23.68],\n",
    "    \"丹东\": [124.37, 40.13],\n",
    "    \"太仓\": [121.1, 31.45],\n",
    "    \"曲靖\": [103.79, 25.51],\n",
    "    \"烟台\": [121.39, 37.52],\n",
    "    \"福州\": [119.3, 26.08],\n",
    "    \"瓦房店\": [121.979603, 39.627114],\n",
    "    \"即墨\": [120.45, 36.38],\n",
    "    \"抚顺\": [123.97, 41.97],\n",
    "    \"玉溪\": [102.52, 24.35],\n",
    "    \"张家口\": [114.87, 40.82],\n",
    "    \"阳泉\": [113.57, 37.85],\n",
    "    \"莱州\": [119.942327, 37.177017],\n",
    "    \"湖州\": [120.1, 30.86],\n",
    "    \"汕头\": [116.69, 23.39],\n",
    "    \"昆山\": [120.95, 31.39],\n",
    "    \"宁波\": [121.56, 29.86],\n",
    "    \"湛江\": [110.359377, 21.270708],\n",
    "    \"揭阳\": [116.35, 23.55],\n",
    "    \"荣成\": [122.41, 37.16],\n",
    "    \"连云港\": [119.16, 34.59],\n",
    "    \"葫芦岛\": [120.836932, 40.711052],\n",
    "    \"常熟\": [120.74, 31.64],\n",
    "    \"东莞\": [113.75, 23.04],\n",
    "    \"河源\": [114.68, 23.73],\n",
    "    \"淮安\": [119.15, 33.5],\n",
    "    \"泰州\": [119.9, 32.49],\n",
    "    \"南宁\": [108.33, 22.84],\n",
    "    \"营口\": [122.18, 40.65],\n",
    "    \"惠州\": [114.4, 23.09],\n",
    "    \"江阴\": [120.26, 31.91],\n",
    "    \"蓬莱\": [120.75, 37.8],\n",
    "    \"韶关\": [113.62, 24.84],\n",
    "    \"嘉峪关\": [98.289152, 39.77313],\n",
    "    \"广州\": [113.23, 23.16],\n",
    "    \"延安\": [109.47, 36.6],\n",
    "    \"太原\": [112.53, 37.87],\n",
    "    \"清远\": [113.01, 23.7],\n",
    "    \"中山\": [113.38, 22.52],\n",
    "    \"昆明\": [102.73, 25.04],\n",
    "    \"寿光\": [118.73, 36.86],\n",
    "    \"盘锦\": [122.070714, 41.119997],\n",
    "    \"长治\": [113.08, 36.18],\n",
    "    \"深圳\": [114.07, 22.62],\n",
    "    \"珠海\": [113.52, 22.3],\n",
    "    \"宿迁\": [118.3, 33.96],\n",
    "    \"咸阳\": [108.72, 34.36],\n",
    "    \"铜川\": [109.11, 35.09],\n",
    "    \"平度\": [119.97, 36.77],\n",
    "    \"佛山\": [113.11, 23.05],\n",
    "    \"海口\": [110.35, 20.02],\n",
    "    \"江门\": [113.06, 22.61],\n",
    "    \"章丘\": [117.53, 36.72],\n",
    "    \"肇庆\": [112.44, 23.05],\n",
    "    \"大连\": [121.62, 38.92],\n",
    "    \"临汾\": [111.5, 36.08],\n",
    "    \"吴江\": [120.63, 31.16],\n",
    "    \"石嘴山\": [106.39, 39.04],\n",
    "    \"沈阳\": [123.38, 41.8],\n",
    "    \"苏州\": [120.62, 31.32],\n",
    "    \"茂名\": [110.88, 21.68],\n",
    "    \"嘉兴\": [120.76, 30.77],\n",
    "    \"长春\": [125.35, 43.88],\n",
    "    \"胶州\": [120.03336, 36.264622],\n",
    "    \"银川\": [106.27, 38.47],\n",
    "    \"张家港\": [120.555821, 31.875428],\n",
    "    \"三门峡\": [111.19, 34.76],\n",
    "    \"锦州\": [121.15, 41.13],\n",
    "    \"南昌\": [115.89, 28.68],\n",
    "    \"柳州\": [109.4, 24.33],\n",
    "    \"三亚\": [109.511909, 18.252847],\n",
    "    \"自贡\": [104.778442, 29.33903],\n",
    "    \"吉林\": [126.57, 43.87],\n",
    "    \"阳江\": [111.95, 21.85],\n",
    "    \"泸州\": [105.39, 28.91],\n",
    "    \"西宁\": [101.74, 36.56],\n",
    "    \"宜宾\": [104.56, 29.77],\n",
    "    \"呼和浩特\": [111.65, 40.82],\n",
    "    \"成都\": [104.06, 30.67],\n",
    "    \"大同\": [113.3, 40.12],\n",
    "    \"镇江\": [119.44, 32.2],\n",
    "    \"桂林\": [110.28, 25.29],\n",
    "    \"张家界\": [110.479191, 29.117096],\n",
    "    \"宜兴\": [119.82, 31.36],\n",
    "    \"北海\": [109.12, 21.49],\n",
    "    \"西安\": [108.95, 34.27],\n",
    "    \"金坛\": [119.56, 31.74],\n",
    "    \"东营\": [118.49, 37.46],\n",
    "    \"牡丹江\": [129.58, 44.6],\n",
    "    \"遵义\": [106.9, 27.7],\n",
    "    \"绍兴\": [120.58, 30.01],\n",
    "    \"扬州\": [119.42, 32.39],\n",
    "    \"常州\": [119.95, 31.79],\n",
    "    \"潍坊\": [119.1, 36.62],\n",
    "    \"重庆\": [106.54, 29.59],\n",
    "    \"台州\": [121.420757, 28.656386],\n",
    "    \"南京\": [118.78, 32.04],\n",
    "    \"滨州\": [118.03, 37.36],\n",
    "    \"贵阳\": [106.71, 26.57],\n",
    "    \"无锡\": [120.29, 31.59],\n",
    "    \"本溪\": [123.73, 41.3],\n",
    "    \"克拉玛依\": [84.77, 45.59],\n",
    "    \"渭南\": [109.5, 34.52],\n",
    "    \"马鞍山\": [118.48, 31.56],\n",
    "    \"宝鸡\": [107.15, 34.38],\n",
    "    \"焦作\": [113.21, 35.24],\n",
    "    \"句容\": [119.16, 31.95],\n",
    "    \"北京\": [116.46, 39.92],\n",
    "    \"徐州\": [117.2, 34.26],\n",
    "    \"衡水\": [115.72, 37.72],\n",
    "    \"包头\": [110, 40.58],\n",
    "    \"绵阳\": [104.73, 31.48],\n",
    "    \"乌鲁木齐\": [87.68, 43.77],\n",
    "    \"枣庄\": [117.57, 34.86],\n",
    "    \"杭州\": [120.19, 30.26],\n",
    "    \"淄博\": [118.05, 36.78],\n",
    "    \"鞍山\": [122.85, 41.12],\n",
    "    \"溧阳\": [119.48, 31.43],\n",
    "    \"库尔勒\": [86.06, 41.68],\n",
    "    \"安阳\": [114.35, 36.1],\n",
    "    \"开封\": [114.35, 34.79],\n",
    "    \"济南\": [117, 36.65],\n",
    "    \"德阳\": [104.37, 31.13],\n",
    "    \"温州\": [120.65, 28.01],\n",
    "    \"九江\": [115.97, 29.71],\n",
    "    \"邯郸\": [114.47, 36.6],\n",
    "    \"临安\": [119.72, 30.23],\n",
    "    \"兰州\": [103.73, 36.03],\n",
    "    \"沧州\": [116.83, 38.33],\n",
    "    \"临沂\": [118.35, 35.05],\n",
    "    \"南充\": [106.110698, 30.837793],\n",
    "    \"天津\": [117.2, 39.13],\n",
    "    \"富阳\": [119.95, 30.07],\n",
    "    \"泰安\": [117.13, 36.18],\n",
    "    \"诸暨\": [120.23, 29.71],\n",
    "    \"郑州\": [113.65, 34.76],\n",
    "    \"哈尔滨\": [126.63, 45.75],\n",
    "    \"聊城\": [115.97, 36.45],\n",
    "    \"芜湖\": [118.38, 31.33],\n",
    "    \"唐山\": [118.02, 39.63],\n",
    "    \"平顶山\": [113.29, 33.75],\n",
    "    \"邢台\": [114.48, 37.05],\n",
    "    \"德州\": [116.29, 37.45],\n",
    "    \"济宁\": [116.59, 35.38],\n",
    "    \"荆州\": [112.239741, 30.335165],\n",
    "    \"宜昌\": [111.3, 30.7],\n",
    "    \"义乌\": [120.06, 29.32],\n",
    "    \"丽水\": [119.92, 28.45],\n",
    "    \"洛阳\": [112.44, 34.7],\n",
    "    \"秦皇岛\": [119.57, 39.95],\n",
    "    \"株洲\": [113.16, 27.83],\n",
    "    \"石家庄\": [114.48, 38.03],\n",
    "    \"莱芜\": [117.67, 36.19],\n",
    "    \"常德\": [111.69, 29.05],\n",
    "    \"保定\": [115.48, 38.85],\n",
    "    \"湘潭\": [112.91, 27.87],\n",
    "    \"金华\": [119.64, 29.12],\n",
    "    \"岳阳\": [113.09, 29.37],\n",
    "    \"长沙\": [113, 28.21],\n",
    "    \"衢州\": [118.88, 28.97],\n",
    "    \"廊坊\": [116.7, 39.53],\n",
    "    \"菏泽\": [115.480656, 35.23375],\n",
    "    \"合肥\": [117.27, 31.86],\n",
    "    \"武汉\": [114.31, 30.52],\n",
    "    \"大庆\": [125.03, 46.58],\n",
    "}\n",
    "\n",
    "\n",
    "def convert_data():\n",
    "    res = []\n",
    "    for i in range(len(data)):\n",
    "        geo_coord = geoCoordMap[data[i][0]]\n",
    "        geo_coord.append(data[i][1])\n",
    "        res.append([data[i][0], geo_coord])\n",
    "    return res\n",
    "\n",
    "(\n",
    "    BMap(init_opts=opts.InitOpts(width=\"1200px\", height=\"800px\"))\n",
    "    .add(\n",
    "        type_=\"effectScatter\",\n",
    "        series_name=\"pm2.5\",\n",
    "        data_pair=convert_data(),\n",
    "        symbol_size=10,\n",
    "        effect_opts=opts.EffectOpts(),\n",
    "        label_opts=opts.LabelOpts(formatter=\"{b}\", position=\"right\", is_show=False),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(color=\"purple\"),\n",
    "    )\n",
    "    .add_schema(\n",
    "        baidu_ak=\"FAKE_AK\",\n",
    "        center=[104.114129, 37.550339],\n",
    "        zoom=5,\n",
    "        is_roam=True,\n",
    "        map_style={\n",
    "            \"styleJson\": [\n",
    "                {\n",
    "                    \"featureType\": \"water\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"color\": \"#044161\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"land\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"color\": \"#004981\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"boundary\",\n",
    "                    \"elementType\": \"geometry\",\n",
    "                    \"stylers\": {\"color\": \"#064f85\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"railway\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"highway\",\n",
    "                    \"elementType\": \"geometry\",\n",
    "                    \"stylers\": {\"color\": \"#004981\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"highway\",\n",
    "                    \"elementType\": \"geometry.fill\",\n",
    "                    \"stylers\": {\"color\": \"#005b96\", \"lightness\": 1},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"highway\",\n",
    "                    \"elementType\": \"labels\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"arterial\",\n",
    "                    \"elementType\": \"geometry\",\n",
    "                    \"stylers\": {\"color\": \"#004981\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"arterial\",\n",
    "                    \"elementType\": \"geometry.fill\",\n",
    "                    \"stylers\": {\"color\": \"#00508b\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"poi\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"green\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"color\": \"#056197\", \"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"subway\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"manmade\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"local\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"arterial\",\n",
    "                    \"elementType\": \"labels\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"boundary\",\n",
    "                    \"elementType\": \"geometry.fill\",\n",
    "                    \"stylers\": {\"color\": \"#029fd4\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"building\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"color\": \"#1a5787\"},\n",
    "                },\n",
    "                {\n",
    "                    \"featureType\": \"label\",\n",
    "                    \"elementType\": \"all\",\n",
    "                    \"stylers\": {\"visibility\": \"off\"},\n",
    "                },\n",
    "            ]\n",
    "        },\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title=\"全国主要城市空气质量\",\n",
    "            subtitle=\"data from PM25.in\",\n",
    "            subtitle_link=\"http://www.pm25.in\",\n",
    "            pos_left=\"center\",\n",
    "            title_textstyle_opts=opts.TextStyleOpts(color=\"#fff\"),\n",
    "        ),\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\"),\n",
    "    )\n",
    "    .render(\"air_quality_baidu_map.html\")\n",
    "#     .load_javascript()\n",
    "#     .render_notebook()\n",
    ")\n",
    "#base_bmap.(\"air_quality_baidu_map.html\")\n",
    "# base_bmap.load_javascript()\n",
    "# base_bmap.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
